/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.helpdesk.dao;

import com.helpdesk.entidades.HdDetalleTicket;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Manuel
 */
@Stateless
public class HdDetalleTicketFacade extends AbstractFacade<HdDetalleTicket> {
    @PersistenceContext(unitName = "WebAppHelpDeskPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public HdDetalleTicketFacade() {
        super(HdDetalleTicket.class);
    }
    
    public int buscarTicketbyEstadoandTecnico(String codEstado, int codTecnico){
        int cantidad_tickets = 0;
        Query q =em.createNamedQuery("HdDetalleTicket.findByEstadoAndTecnico");  
        q.setParameter("codEstado", codEstado);
        q.setParameter("codTecnico",codTecnico);
        cantidad_tickets = Integer.parseInt(q.getSingleResult().toString());
        return cantidad_tickets;
    }
    public List<HdDetalleTicket> listaAsignaTec (int codTecnico) {
        List<HdDetalleTicket> lista=null;
         Query q=em.createNamedQuery("HdDetalleTicket.findByInbox");
         q.setParameter("codTecnico", codTecnico);
         lista=q.getResultList();
        return lista;
    }
    
}
